Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Low Code Carbon Credit Implementation #22

Open
wants to merge 18 commits into
base: main
Choose a base branch
from

Conversation

parv0888
Copy link
Contributor

Purpose

Adds Carbon Credit Sample Implementation.

Changes

Adds Marketplace, Carbon Project Fractionalizer to Carbon Credits & Carbon Project NFT contracts.
Adds Frontend to interact with the contracts and backend
Adds backend & Indexer / Listener to listen for a process events from the contracts.

Checklist

  • My code follows the style of this project.
  • The code compiles without warnings.
  • I have performed a self-review of the changes.
  • I have documented my code, in particular the intent of the
    hard-to-understand areas.
  • (If necessary) I have updated the CHANGELOG.

CLA acceptance

By submitting the contribution I accept the terms and conditions of the
Contributor License Agreement v1.0

@parv0888 parv0888 changed the title added carbon credit contracts Low Code Carbon Credit Implementation Aug 17, 2023
.gitmodules Outdated Show resolved Hide resolved
@DOBEN DOBEN self-requested a review August 22, 2023 13:06
@parv0888
Copy link
Contributor Author

@DOBEN : Kindly note that changes which were done in the previous PR related to Metadata URL also would have to be done in this PR since the same approch was used. Im on it.

@parv0888 parv0888 marked this pull request as ready for review August 23, 2023 01:56
@parv0888 parv0888 requested a review from DOBEN August 23, 2023 22:35
Copy link
Member

@DOBEN DOBEN left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works very well.

I had a problem with buying the tokens from the marketplace. I think initially the logic was to call updateOperator and then to sell a token by transferring it from the seller account to the buyer account. Now the front end transfers the token to the marketplace and then when buying a token the token needs to be transferred from the marketPlaceContract to the buyer account. Currently, the smart contract logic still uses the seller account to the buyer account which results in an -4 error.

https://github.com/Concordium/concordium-dapp-examples/blob/53a9e11df4117131ed2498[…]dits-marketplace/contracts/src/carbon_credit_market/transfer.rs

        .cis2
        .transfer::<State<S>, ContractTokenId, ContractTokenAmount, ()>(
            host,
            Transfer {
                amount: params.quantity,
                to: Receiver::Account(params.to),
                token_id: params.token_id,
                from: Address::Account(params.owner),
                data: AdditionalData::empty(),
            },
        )?;

    logger.log(&ContractEvent::TokenTransferred(TokenTransferredEvent {
        token_id: params.token_id,
        token_contract: params.cis_contract_address,
        from: Address::Account(params.owner),
        to: Address::Account(params.to),
        amount: params.quantity,
    }))?;

There is an issue when using googleMail:

  • buying a token when log-in with googleMail (error: Private key as second argument is required)

low-code-carbon-credits-marketplace/README.md Show resolved Hide resolved
@parv0888
Copy link
Contributor Author

Works very well.

I had a problem with buying the tokens from the marketplace. I think initially the logic was to call updateOperator and then to sell a token by transferring it from the seller account to the buyer account. Now the front end transfers the token to the marketplace and then when buying a token the token needs to be transferred from the marketPlaceContract to the buyer account. Currently, the smart contract logic still uses the seller account to the buyer account which results in an -4 error.

https://github.com/Concordium/concordium-dapp-examples/blob/53a9e11df4117131ed2498[…]dits-marketplace/contracts/src/carbon_credit_market/transfer.rs

        .cis2
        .transfer::<State<S>, ContractTokenId, ContractTokenAmount, ()>(
            host,
            Transfer {
                amount: params.quantity,
                to: Receiver::Account(params.to),
                token_id: params.token_id,
                from: Address::Account(params.owner),
                data: AdditionalData::empty(),
            },
        )?;

    logger.log(&ContractEvent::TokenTransferred(TokenTransferredEvent {
        token_id: params.token_id,
        token_contract: params.cis_contract_address,
        from: Address::Account(params.owner),
        to: Address::Account(params.to),
        amount: params.quantity,
    }))?;

There is an issue when using googleMail:

  • buying a token when log-in with googleMail (error: Private key as second argument is required)

Thanks @DOBEN
this has been fixed.

@DOBEN
Copy link
Member

DOBEN commented Sep 4, 2023

@parv0888 There is something not picked up in the TransferEvent in the Fractionalizer contract. It looks to me related to the above changes. E.g. that the front end expects an AccountAddress as the By field but it is a smart contract address now.

See the associated event By field is empty when checking the events in the Fractionalizer contract now. This field should not be empty.
Screenshot from 2023-09-04 10-38-00.

I wonder if the intention of the indexer is to pick up all the CIS2 Transfer events from a specific token contract or only a subset of it? Are these Transfer events the Transfer event as specified in the CIS2 standard or some custom Transfer events? E.g. are the indexer only picking up a subset of Transfer events e.g. only the ones that go from an account address to the carbonCreditMarketPlace?

There are no Transfer events from the account to the carbonCreditMarketplaceSmartContract currently. Just wonder if that is intended or not (equally for the project token)?

@DOBEN
Copy link
Member

DOBEN commented Sep 4, 2023

Please add a note about this project and the low-code-nft-marketplace in the Read.me:
https://github.com/Concordium/concordium-dapp-examples/blob/main/README.md

@DOBEN
Copy link
Member

DOBEN commented Sep 4, 2023

Screenshot from 2023-09-04 11-09-34

I have used the private key as REACT_APP_WERT_PRIVATE_KEY that was provided to me and used the remaining environmental variables for WERT/GOOGLE_AUTHENTICATE as they were from the previous PR before they were removed. Seems there is something else I need to set up differently.

@parv0888
Copy link
Contributor Author

parv0888 commented Sep 4, 2023

HI @DOBEN
I did test this and also have sent you the changes on linkedin.
seems to be working for me. Please do specify is the provided values does not work for you.
Please do try any other gmail / google account once.

Thanks

@parv0888
Copy link
Contributor Author

parv0888 commented Sep 4, 2023

@parv0888 There is something not picked up in the TransferEvent in the Fractionalizer contract. It looks to me related to the above changes. E.g. that the front end expects an AccountAddress as the By field but it is a smart contract address now.

See the associated event By field is empty when checking the events in the Fractionalizer contract now. This field should not be empty. Screenshot from 2023-09-04 10-38-00.

I wonder if the intention of the indexer is to pick up all the CIS2 Transfer events from a specific token contract or only a subset of it? Are these Transfer events the Transfer event as specified in the CIS2 standard or some custom Transfer events? E.g. are the indexer only picking up a subset of Transfer events e.g. only the ones that go from an account address to the carbonCreditMarketPlace?

There are no Transfer events from the account to the carbonCreditMarketplaceSmartContract currently. Just wonder if that is intended or not (equally for the project token)?

This has been fixed

@DOBEN DOBEN self-requested a review September 5, 2023 10:31
Copy link
Member

@DOBEN DOBEN left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done. The project looks very good in general.

yarn start:ui
```

* Wert integration is **disabled by default**. To enable it, set thefollowing environment variables in the [.env](./market-ui/.env) file. Contract [Wert sales](https://wert.io/for-partners) to get these credentials
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Wert integration is **disabled by default**. To enable it, set thefollowing environment variables in the [.env](./market-ui/.env) file. Contract [Wert sales](https://wert.io/for-partners) to get these credentials
* Wert integration is **disabled by default**. To enable it, set the following environment variables in the [.env](./market-ui/.env) file. Contact [Wert sales](https://wert.io/for-partners) to get these credentials

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants